// 加载时获取当前状态
chrome.storage.local.get(['enabled'], (result) => {
    document.getElementById('autoPlayToggle').checked = result.enabled ?? true;
});

// 监听开关变化
document.getElementById('autoPlayToggle').addEventListener('change', (e) => {
    const enabled = e.target.checked;
    chrome.storage.local.set({ enabled });
}); 